package com.lx.patterns.interpreter;

/**
 * @ClassName Variable
 * @Description: 终结符表达式角色 变量表达式
 * @Author: 落雪
 * @CreateDate: 2025/2/15 16:22
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/2/15 16:22
 * @UpdateRemark:
 * @Version: 1.0
 */
public class Variable implements AbstractExpression {

    private String name;

    public Variable(String name) {
        this.name = name;
    }
    @Override
    public int interpret(Context context) {
        return context.getValue(this);
    }

    @Override
    public String toString() {
        return name;
    }
}
